<template>
  <div class="refine_sosOrganization" :style="{'height':fheight}">
    <h2 class="titleblue">搜救机构</h2>
    <div class="contant">
      <div class="main">
        <div class="orgbtn fl"><label class="create bgblue">{{sosOrgName}}</label><em></em></div>

        <div class="listItem">
          <ul>
            <li :class="index==level1?'activeli':''" v-for="(item,index) in sos" class="itemlison">
              <hr></hr>
              <div class="itemson" @click='actived(index,item.id,item.name)'>
                <em :class="index==level1||!item.subset?'el-icon-minus':'el-icon-plus'"
                    style="cursor: pointer;"></em>
                <span :class="index==level1?'active':''" style="cursor: pointer;">{{item.name}}</span></div>
              <hr style="width:215px" v-if="index==level1&&item.subset"></hr>

              <div class="items-cont" id="ul2">
                <ul v-if='index==level1'>
                  <li v-for="(item1,index1) in item.subset" :class='index1==item.subset.length-1&&item1.oneph3?"margin50":"margin25"'>
                    <div class="item-title" @click='actived2(index1,item1.id,item1.name)'>
                    <hr></hr>
                      <em class="el-icon-minus"></em><span :class="index1==level2?'active':''" style="cursor: pointer;">{{item1.name}}</span>
                    </div>
                    <div class="item-phone active" v-if="item1.oneph1">
                      <i class="el-icon-phone-outline"></i>
                      {{item1.oneph1}}
                    </div>
                    <div class="item-phone active" v-if="item1.oneph2">
                      <i class="el-icon-phone-outline"></i>
                      {{item1.oneph2}}
                    </div>
                    <div class="item-phone active" v-if="item1.oneph3">
                      <i class="el-icon-phone-outline"></i>
                      {{item1.oneph3}}
                    </div>
                  </li>
                </ul>
              </div>

            </li>
          </ul>
        </div>

      </div>
    </div>
  </div>
</template>

<script>
  import sosOrgService from '@/services/SosOrgService'

    export default {
      data: function () {
        return {
          sosOrgid:'',
          sosOrgName:'',
          sos: [],
          level1: -1,
          fheight: '1150px',
          level2: -1
        }
      },
      created () {
        this.sosOrgid=this.$route.query.id
        this.getTreeData();
      },
      mounted() {
      },
      methods: {
          getTreeData () {
            sessionStorage.setItem('guarantee_sosorgid',this.sosOrgid);
            this.sosOrgName='';
            sosOrgService.searchTree('').then(res => {
              for (let i=0;i<res.length;i++){
                if (res[i].id==this.sosOrgid){
                  this.sosOrgName=res[i].name;
                  this.sos = res[i].subset;
                  break;
                }
              }
            })
          },
        actived (index,id,name) {
          this.level1 = index
          sessionStorage.setItem('guaranteeSosorgidTreeSelect',id);
          this.level2=-1
        },
        actived2 (index,id,name) {
            this.level2=index
          sessionStorage.setItem('guaranteeSosorgidTreeSelect',id);
        },
      },
      watch:{
        '$route' (to,from){
          if (to.name=="SosOrgTree"){
            this.sosOrgid=this.$route.query.id
            this.getTreeData();
          }
        }
      }
    }
</script>

<style scoped lang="scss">
  .refine_sosOrganization {
    width: 100%;
    display: inline-block;
    padding-bottom: 50px;
    min-height: 500px;

    .main {
      width: 100%;
      display: inline-block;
      position: relative;
      margin-top: 50px;
      padding-left: 50px;
      box-sizing: border-box;
    }

    .orgbtn {
      position: absolute;
      left: 50px;
      top: 50%;
      margin-top: -24px;
    }

    .orgbtn em {
      height: 1px;
      width: 30px;
      background: #aaa;
      margin-top: 19px;
      float: left;
      margin-left: -10px;
    }

    .orgbtn .bgblue {
      background: rgb(41, 139, 245)
    }

    .edit-icon {
      float: left;
      margin-top: 5px;
    }

    .listItem {
      margin-left: 160px;
      position: relative;
    }

    .listItem ul {
      border-left: 1px solid #aaa;
    }

    .activeli {
      position: relative;
      z-index: 99;
    }

    .listItem li em {
      padding: 0px;
      font-size: 12px;
      margin-right: 10px;
      border: 1px solid #aaa;
      color: #333;
      float: left;
      margin-top: 6px;
    }

    .listItem li {
      margin-bottom: 10px;
    }

    .listItem li:first-child {
      transform: translateY(-50%) !important;
      margin-bottom: 0px !important;
      margin-top: 0 !important;
    }

    .listItem li:last-child {
      transform: translateY(46%);
      margin-top: -10px;
    }

    .listItem li:after {
      content: '';
      display: block;
      clear: both;
    }

    .listItem li hr {

      width: 30px;
      transform: translateY(-150%);
      margin-left: -1px;
      margin-top: 15px;
      float: left;
    }

    .listItem li span {
      float: left;
    }

    .listItem li .active {
      color: rgb(41, 139, 245);
    }

    .listItem li.active em {
      color: #ccc;
    }

    .itemson span {
      position: relative;
      /*z-index: 9999;*/
    }

    .itemson {
      float: left;
    }

    .items:after {
      content: '';
      display: block;
      clear: both;
    }

    .items {
      position: absolute;
      float: left;
      margin-top: 6px;
      left: 258px;
      top: -50px;
      background: #fff;
      z-index: 99;
      padding-top: 10px;
    }

    .items li {
      position: relative;
      z-index: 99;
    }

    .items-cont {
      position: absolute;
      left: 314px;
      top: 0px;
      background: #fff;
      width: 300px;
      margin-left: -2px;
    }

    .items-cont li:first-child {
      transform: translateY(0%) !important;
      margin-bottom: 0px !important;
      top: -14px !important;
      position: relative;
      width: 300px;
    }

    .items-cont .margin50 {
      transform: translateY(0%) !important;
      margin-top: 0px !important;
      height: 13px;
    }

    .items-cont .margin50:first-child {
      height: 13px;
    }

    .items-cont .margin25:last-child {
      transform: translateY(0%);
      margin-top: 0px;
      top: 0;
      height: 12px;
    }

    .item-phone {
      position: relative;
      left: 55px;
    }

    .el-icon-phone-outline {
      margin-right: 5px;
    }

    .item-title {
      width: 100%;
      float: left;
    }
  }

</style>
